<?php
/**
 *      [迷你云] (C)2009-2012 南京恒为网络科技.
 *   软件仅供研究与学习使用，如需商用，请访问www.miniyun.cn获得授权
 * 
 */
?>
<?php

class CMiniyunModel extends CActiveRecord
{

	
	public function beforeSave()
	{
		if ($this->isNewRecord)
		{
			$this->created_at = new CDbExpression('NOW()');
		}
		$this->updated_at = new CDbExpression('NOW()');
		return true;

	}
	
	public function getIds($data,$key="id"){
		$ids = "";
		foreach($data as $index=>$item){
			if(strlen($ids)>0){
				$ids = $ids.",";
			}
			$ids = $ids.$item[$key];
		}
		return $ids;
	}
	
	
	public function primaryKey(){
	    if (parent::primaryKey() == "") {
	        return "id";
	    }
	    return parent::primaryKey();
	}
}